<?php
/* WARNING! It's created by a while because it's needed. There is NO valid regex for reading info from config.lua... it'll be later. */

class configParser {
	private static $data = array();
	public static $confdir = '';
	public static $conffile = '';

	public static function parse( $configpath, $configfile )
	{
		$REGEX = "/\s*([A-Za-z_-]+)\s*=\s*['\"\{]?([A-Za-z0-9\-_ \.,:\/\\\\]+)?[\}'\"]?/";
		$file = file( $configpath.$configfile );
		self::$confdir = $configpath;
		self::$conffile = $configfile;
		
		foreach( $file as $line )
		{
			$match = array();
			if( preg_match( $REGEX, $line, $match ) )
			{
				self::$data[$match[1]] = $match[2];
			}
		}
	
		if( empty(self::$data) )
			throw new LogicException();
			
		return true;
	}
	
	public static function getData( $d )
	{
		return self::$data[$d];
	}
		
}
?>